﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace DFGK_WMS.Model.Models
{
    /// <summary>
    /// 出库单明细
    /// </summary>
    [Table("T_ShippingOrderDetail")]
    public class ShippingOrderDetail:BaseEntity
    {   
        /// <summary>
        /// 出库订单号
        /// </summary>
        public string OrderSn { get; set; }

        /// <summary>
        /// 单据类型 1-整托出库 2-拣选出库
        /// </summary>
        public int? BillType { get; set; }

        /// <summary>
        /// 优先级:默认为0
        /// </summary>
        public int? Proirity { get; set; }

        /// <summary>
        /// 状态：0-新建;1-提交；2-审核通过;3-作业中;4-已完成;5-强制完成;6-失效;7-异常
        /// </summary>
        public int Status { get; set; }

        /// <summary>
        /// 库房编码
        /// </summary>
        [MaxLength(60)]
        public string WarehouseCode { get; set; }
        /// <summary>
        /// 其他单据类型
        /// </summary>
        public string OtherTypeCode { get; set; }

        /// <summary>
        /// 库房名称
        /// </summary>
        [MaxLength(60)]
        public string WarehouseName { get; set; }

        /// <summary>
        /// 库区编码
        /// </summary>
        [MaxLength(60)]
        public string AreaCode { get; set; }

        /// <summary>
        /// 库区名称
        /// </summary>
        [MaxLength(60)]
        public string AreaName { get; set; }

        /// <summary>
        /// 物料ID
        /// </summary>
        public long MaterialId { get; set; }

        /// <summary>
        /// 物料号
        /// </summary>
        [MaxLength(60)]
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        [MaxLength(60)]
        public string MaterialName { get; set; }
        /// <summary>
        /// 产品编号
        /// </summary>
        [MaxLength(60)]
        public string ProductCode { get; set; }
        /// <summary>
        /// 产品名称
        /// </summary>
        [MaxLength(60)]
        public string ProductName { get; set; }
        /// <summary>
        /// 产品计量单位
        /// </summary>
        [MaxLength(60)]
        public string ProductUnitName { get; set; }
        /// <summary>
        /// 产品型号规格
        /// </summary>
        [MaxLength(50)]
        public string ProductModelSpec { get; set; }
        /// <summary>
        /// 产品生产数量
        /// </summary>
        public int ProductQty { get; set; }
        /// <summary>
        /// 生产任务单编号
        /// </summary>
        [MaxLength(60)]
        public string ProOrderNo { get; set; }

        /// <summary>
        /// 部门编码
        /// </summary>
        [MaxLength(60)]
        public string DeptCode { get; set; }

        /// <summary>
        /// 部门名称
        /// </summary>
        [MaxLength(60)]
        public string DeptName { get; set; }
        /// <summary>
        /// 单据时间
        /// </summary>
        public DateTime BillDate { get; set; }
        /// <summary>
        /// 客户编码
        /// </summary>
        [MaxLength(60)]
        public string CustomCode { get; set; }
        /// <summary>
        /// 收货单位
        /// </summary>
        [MaxLength(60)]
        public string SendOrgan { get; set; }
        /// <summary>
        /// 收获地址
        /// </summary>
        [MaxLength(60)]
        public string SendAddress { get; set; }


        /// <summary>
        /// 物料类型码
        /// </summary>
        [MaxLength(60)]
        public string MaterialTypeCode { get; set; }

        /// <summary>
        /// 批次号
        /// </summary>
        [MaxLength(60)]
        public string BatchNo { get; set; }

        /// <summary>
        /// 质量状态
        /// </summary>
        public int? QualityState { get; set; }

        /// <summary>
        /// 计量单位
        /// </summary>
        public long? UnitId { get; set; }

        /// <summary>
        /// 计量单位名称
        /// </summary>
        public string UnitName { get; set; }
  
        /// <summary>
        /// 预期出货数量
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal? Qty { get; set; } = 0;

        /// <summary>
        /// 出库站台Id
        /// </summary>
        public long? StationId { get; set; }

        /// <summary>
        /// 预期出库站台或站台组
        /// </summary>
        [MaxLength(60)]
        public string StationName { get; set; }

        /// <summary>
        /// erp编码
        /// </summary>
        [MaxLength(60)]
        public string Erpcode { get; set; }

        /// <summary>
        /// 包装数量(总出库数量)
        /// </summary>
        public int? PackQty { get; set; } = 0;

        /// <summary>
        /// 已经下架的数量
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal? PickedQty { get; set; } = 0;

        /// <summary>
        /// 已经出库完成的数量
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal? ShippedQty { get; set; } = 0;

        /// <summary>
        /// 订单完成日期
        /// </summary>
        public DateTime? FinshDate { get; set; }

        /// <summary>
        /// 单据来源类型：0-手动建单；1-ERP;2-MES;3-SAP;4-WCS
        /// </summary>
        public int? SourceType { get; set; }

       
        /// <summary>
        /// 提交人Id
        /// </summary>
        public int? SubmitUserId { get; set; }

        /// <summary>
        /// 提交人
        /// </summary>
        public string SubmitUserName { get; set; }

        /// <summary>
        /// 提交时间
        /// </summary>
        public DateTime? SubmitDate { get; set; }

        /// <summary>
        /// 审核人Id
        /// </summary>
        public int? AuditUserId { get; set; }

        /// <summary>
        /// 审核人
        /// </summary>
        public string AuditUserName { get; set; }

        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime? AuditDate { get; set; }

        /// <summary>
        /// 物料凭证号
        /// </summary>
        [MaxLength(60)]
        public string Mblnr { get; set; }

        /// <summary>
        /// 物料凭证年度
        /// </summary>
        [MaxLength(60)]
        public string Mjahr { get; set; }

        /// <summary>
        /// 物料凭证行项目
        /// </summary>
        [MaxLength(60)]
        public string Zeile { get; set; }

        /// <summary>
        /// (另用 同步状态)采购订单号
        /// </summary>
        [MaxLength(60)]
        public string PurOrderNo { get; set; }

        /// <summary>
        /// 采购订单行号
        /// </summary>
        public string PurOrderLineNo { get; set; }

        /// <summary>
        /// 采购订单行项目类型：3.生产投料4.生产报废补料单5.调拨单(成品发货部分)
        /// </summary>
        public int? PurOrderLineType { get; set; }



        /// <summary>
        /// 发货单号
        /// </summary>
        [MaxLength(60)]
        public string DisOrderNo { get; set; }

        /// <summary>
        /// 发货单行号
        /// </summary>
        [MaxLength(60)]
        public string DisOrderLineNo { get; set; }

        /// <summary>
        /// 关联出库凭据Id
        /// </summary>
        public int? RefOutVoucherId { get; set; }

        /// <summary>
        /// 关联发货单Id
        /// </summary>
        public int? RefDispatchOrderId { get; set; }

        /// <summary>
        /// 合同编号
        /// </summary>
        [MaxLength(60)]
        public string ContractNo { get; set; }

        /// <summary>
        /// 是否多托盘
        /// </summary>
        public bool? IsMultPallet { get; set; }

        /// <summary>
        /// 是否挂起
        /// </summary>
        public bool? IsSuspend { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public long? WarehouseId { get; set; }

        /// <summary>
        /// 是否出库核审
        /// </summary>
        public bool? IsOutOrderReview { get; set; } = false;

        /// <summary>
        /// 是否一次出库
        /// </summary>
        public bool? IsOnceOut { get; set; }

        /// <summary>
        /// 生成厂家
        /// </summary>
        [MaxLength(60)]
        public string ProduceFactory { get; set; }

        /// <summary>
        /// 供应商名称
        /// </summary>
        [MaxLength(60)]
        public string SupplierName { get; set; }

        /// <summary>
        /// 供应商Id
        /// </summary>
        public long? SupplierId { get; set; }
        /// <summary>
        /// 客户id
        /// </summary>
        public long? CustomerId { get; set; }
        /// <summary>
        /// 客户名称
        /// </summary>
        [MaxLength(60)]
        public string CustomerName { get; set; }

        /// <summary>
        /// 托盘条码
        /// </summary>
        [NotMapped]
        public string PalletBarcode { get; set; }    

        [NotMapped]
        public List<ShippingLockCell> LockCellList { get; set; } =new List<ShippingLockCell>();
    }
}